package com.hnevc.charpt3.encapsulation;

public class Student {
	private String name;
	//私有成员变量
	private int age; 
	
	//公共读取属性的方法getXxx()
	public int getAge() { 
		return age;
	}
	//公共设置属性的方法setXxx()
	public void setAge(int age) {
		this.age = age;
	}
	
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	

	public void introduce(){
		System.out.println("大家好,我叫"+name+",我今年"+age+"岁");
	}
	
	
	public static void main(String[] args){
		Student student = new Student();
		student.name ="黎明";
		student.age = -9;
		student.introduce();
	}
}
